﻿if (typeof LS == 'undefined') {
    var LS = {};
}
if (typeof OA == 'undefined') {
    var OA = {};
}
BaseModel = function (method) {
    this.Method = method;
    if (this.Method)
        this.Method();
}
BaseModel.prototype = {
    RaisePropertyChanged: function (name, value) {
        this.ModifyInfos[name] = value;
    },
    SetData: function (fieldName, value) {
        if (fieldName != "" && typeof this.Data[fieldName] != "undefined" && this.Data[fieldName] != undefined && this.Data[fieldName] != null && this.Data[fieldName] !== value) {
            this.Data[fieldName] = value;
            this.RaisePropertyChanged(fieldName, value);
        }
    },
    InitFields: function (owner, callMethod) {
        this.InitFieldsing();
        for (var p in owner.Fields) {
            this.Data[p] = "";
            owner[p] = new Field(p, owner, function (value) {
                if (callMethod)
                    callMethod(value);
            });
        }
    }
}
//全部参数存储，否则未存储的是共用,setMethod原方法中访问不到 Field;
function Field(fieldName, owner, setMethod) {
    this.FieldName = fieldName;
    this.Value = "";
    this.Set = function (value) {
        owner.SetData(this.FieldName, value);
        if (setMethod) {
            setMethod(value);
            this.Value = value;
        }
    };
}